// pages/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    start: 0,
    loading:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
     this.loadData()
  },
  loadData(){
    if(!this.data.loading){
      wx.showLoading({
        title: '拼命加载中...'
      })
    }
    this.setData({
      loading:true
    })
    wx.request({
      url: `https://data.miaov.com/h5-view/v/movie/list?page_start=${this.data.start}`,
      success: (res) => {
        this.data.start +=10
        this.setData({
          list: this.data.list.concat(res.data.subjects),
          loading:false
        })
        wx.hideLoading()
      },
    })
    
  },
  tap(e){
    wx.navigateTo({
      url: '/pages/detail/detail?id=' + e.currentTarget.dataset.id,
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
   this.loadData()
  }
})